/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __IMPL_RSA_MGR_H__
#define __IMPL_RSA_MGR_H__

#include "include_openssl.h"
#include "../tools/head.h"

namespace xos_encrypt
{

    class rsa_mgr : public xos_stl::mem_item< xos::release_impl< rsa_mgr >, thread_lock >,
		public i_rsa_mgr
    {
    public:
        typedef xos::release_impl< rsa_mgr > T;

    public:
        static int get_xos_item_data( ITEM_DATA*& item_ptr );

    public:
        rsa_mgr();
        ~rsa_mgr();

    public:
        // rsa方法
        int set_rsa_private_key( const char* lpszFile );
        int set_rsa_public_key( const char* lpszFile );
        int init_rsa();
        i_rsa* rsa();

    public:
        std::string m_private_key_file;
        std::string m_public_key_file;

        void* m_pPrivateRSA;
        void* m_pPublicRSA;

        int m_nRsaLen;

    protected:
        int init_data();
        int term_rsa();

    public:
        int init();
        int term();
    };

} // xos_encrypt

#endif // __IMPL_RSA_MGR_H__
